// Copyright  2004-2008 Backplane Ltd.
//
// This file is part of Ubiquity formsPlayer
//
// Ubiquity formsPlayer is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3 of the License, or (at your
// option) any later version.
//
// Ubiquity formsPlayer is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License
// along with Ubiquity formsPlayer If not, see <http://www.gnu.org/licenses/>.
//	
//
//   Purpose: implementation of CXPathResultNodesetWrapper.
//   $Id$


#include "stdafx.h"
#include "XPathResultNodesetWrapper.h"

CXPathResultNodesetWrapper::CXPathResultNodesetWrapper(IXPathResult * pResult)
	:m_pResult(pResult)
{
	short t;
	m_pResult->get_resultType(&t);
	switch(t)
	{
		case UNORDERED_NODE_ITERATOR_TYPE:
		case ORDERED_NODE_ITERATOR_TYPE:
		case UNORDERED_NODE_SNAPSHOT_TYPE:
		case ORDERED_NODE_SNAPSHOT_TYPE:
		case ANY_UNORDERED_NODE_TYPE:
		case FIRST_ORDERED_NODE_TYPE:
			break;
		default:
			throw;
	}
	
}

CXPathResultNodesetWrapper::~CXPathResultNodesetWrapper()
{

}

HRESULT CXPathResultNodesetWrapper::GetNodeAt(const long lIndex, IXMLDOMNode **ppRetval)
{
	return m_pResult->snapshotItem(lIndex,ppRetval);
}

long CXPathResultNodesetWrapper::GetNodesetLength()
{
	unsigned long l;
	m_pResult->get_snapshotLength(&l);
	return static_cast<long>(l);
}
